Crate zenoh_keyexpr

source ·
Expand description

Key expression are Zenoh’s address space.

In Zenoh, operations are performed on keys. To allow addressing multiple keys with a single operation, we use Key Expressions (KE). KEs are a small language that express sets of keys through a glob-like language.

These semantics can be a bit difficult to implement, so this module provides the following facilities:

§Storing Key Expressions

This module provides 2 flavours to store strings that have been validated to respect the KE syntax, and a third is provided by zenoh:

  • keyexpr is the equivalent of a str,
  • OwnedKeyExpr works like an [Arc<str>],
  • KeyExpr works like a [Cow<str>], but also stores some additional context internal to Zenoh to optimize routing and network usage.

All of these types Deref to keyexpr, which notably has methods to check whether a given keyexpr::intersects with another, or even if a keyexpr::includes another.

§Tying values to Key Expressions

When storing values tied to Key Expressions, you might want something more specialized than a HashMap if you want to respect the Key Expression semantics with high performance.

Enter KeTrees. These are data-structures specially built to store KE-value pairs in a manner that supports the set-semantics of KEs.

§Building and parsing Key Expressions

A common issue in REST API is the association of meaning to sections of the URL, and respecting that API in a convenient manner. The same issue arises naturally when designing a KE space, and KeFormat was designed to help you with this, both in constructing and in parsing KEs that fit the formats you’ve defined.

[kedefine] also allows you to define formats at compile time, allowing a more performant, but more importantly safer and more convenient use of said formats, as the [keformat] and [kewrite] macros will be able to tell you if you’re attempting to set fields of the format that do not exist.

Re-exports§

Modules§

  • This module implements the Key Expression Language, as explained in details in keyexpr’s documentation.
  • KeTrees are specialized data structures to work with sets of values addressed by key expressions.